package L1;

import java.util.Scanner;

public class _049 {
    /**
     * 天梯赛座位分配
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N  = scanner.nextInt();
        int[] arr = new int[N];
        int max=Integer.MIN_VALUE;
        for (int i = 0; i <N ; i++) {
            arr[i] = scanner.nextInt();
            if (max<arr[i]){
                max=arr[i];
            }
        }
        int[] school = new int[N];
        int[][] res = new int[N][100];
        int num=1;
        if (N==1){
            num=0;
        }
        for (int i=0;i<max*10;i++){
            for (int j=0;j<N;j++){
                if (i<arr[j]*10){
                    int n=0;
                    for (int k=0;k<N;k++){
                        if (school[k]==0){
                            n++;
                        }
                    }
                    if (n==1){
                        num+=1;
                        res[j][i]=num++;
                    }else {
                        res[j][i]=num++;
                    }
                }else {
                    school[j]=1;
                }
            }
        }
        for (int i=0;i<N;i++){
            System.out.println("#"+(i+1));
            for (int j =0;j<arr[i]*10;j++){
                if (j%10==0&&j!=0){
                    System.out.println();
                }else if (j!=0){
                    System.out.print(" ");
                }
                System.out.print(res[i][j]);
            }
            System.out.println();
        }
    }
}
